using System;
using Toast.Core;
using Toast.Core.Interfaces;

namespace Toast.Compression
{
    public static class CompressorFactory
    {
        public static ICompressionStrategy Get<TCompression>() where TCompression : ICompressionStrategy, new()
        {
            return new TCompression {CompressionLevel = CompressionLevel.Normal};
        }

        public static ICompressionStrategy Get(Type compressionType)
        {
            var r = (ICompressionStrategy)Activator.CreateInstance(compressionType);
            return r;
        }

        public static ICompressionStrategy Get(Type compressionType, CompressionLevel compressionLevel)
        {
            var r = Get(compressionType);
            r.CompressionLevel = compressionLevel;
            return r;
        }

        public static ICompressionStrategy Get<TCompression>(CompressionLevel compressionLevel) where TCompression : ICompressionStrategy, new()
        {
            return new TCompression {CompressionLevel = compressionLevel};
        }
    }
}